import re

def count_word_frequency(filepath):
    try:
        with open(filepath, 'r', encoding='utf-8') as f:
            text = f.read().lower()
            cleaned_text = re.sub(r'[^\w\s]', '', text)
            words = cleaned_text.split()
            word_count = {}
            for word in words:
                word_count[word] = word_count.get(word, 0) + 1
            sorted_word_count = sorted(word_count.items(), key=lambda item: item[1], reverse=True)
            print("单词词频统计结果:")
            for word, count in sorted_word_count[:10]: 
                print(f"'{word}': {count}")
    except FileNotFoundError:
        print(f"错误: 文件 '{filepath}' 未找到。")

count_word_frequency('test2.txt')